﻿using System;
using System.Collections.Generic;
using System.Text;


namespace SmartMovieTime
{
    class Singleton<T>
        where T : IDisposable, new()
    {
        private static T instance;

        private Singleton()
        {
        }

        static Singleton()
        {
            instance = default(T);
        }

        public static T Instance()
        {
            
            if (instance == null)
            {
                instance = new T();
            }

            return instance;
    
        }

        public static void Close()
        {
            instance.Dispose();
        }
    }
}
